'use strict';
module.exports = {
  /**
   * 查询模版列表
   * @url client/template/pub/getList 前端调用的url参数地址
   * data 请求参数
   * @param {String} params1  参数1
   */
  main: async (event) => {
    let {
      data = {}, userInfo, util, filterResponse, originalParam
    } = event;
    let {
      customUtil,
      uniID,
      config,
      pubFun,
      vk,
      db,
      _
    } = util;
    let {
      uid
    } = data;
    let res = {
      code: 0,
      msg: ""
    };
    // // 业务逻辑开始-----------------------------------------------------------
    const dbName = "ai-goods";
    const {
      pageIndex = 1, pageSize = 20
    } = data;

    try {
      const sql = {
        dbName, // 表名
        getCount: false, // 是否需要同时查询满足条件的记录总数量，默认false
        getMain: false, // 是否只返回rows数据，默认false
        pageIndex, // 当前第几页
        pageSize, // 每页条数
        whereJson: {
          is_online: 1,
          is_deleted: 0
        },
        fieldJson: {
          "network_disk_path": false,
          "order": false,
          "keyword": false
        },
        sortArr: [{
            "name": "order",
            "type": "desc"
          },
          {
            "name": "created_at",
            "type": "desc"
          }
        ]
      }
      res = await vk.baseDao.select(sql);
    } catch (err) {

      res = {
        code: 500,
        msg: "查询错误",
        err
      };
    }

    // 业务逻辑结束-----------------------------------------------------------
    return res;
  }
}